﻿Public Class FormMes
    Dim objPgdMes As New clsPgdMes
    Dim objWorkshopCurrent As New clsWorkshopCurrent
    Dim objSysParam As New clsSysParam
    Dim current_section As String '当前工序
    Dim ping = New Net.NetworkInformation.Ping()
    Private Sub FormMes_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        current_section = GetIniFile("SECTION", "current_section", "", g_szInitFileName)
        setDgvData()
    End Sub

    Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
        setDgvData()
    End Sub

    Private Sub setDgvData()
        Dim dt As DataTable = objPgdMes.getList("预组装", txtFlbType.Text.Trim())
        'If dt.Rows.Count > 0 Then
        '    dt.Columns.Add("validity_name")
        '    For Each row As DataRow In dt.Rows
        '        If row("validity") = "0" Then
        '            row("validity_name") = "无效"
        '        Else
        '            row("validity_name") = "有效"
        '        End If
        '    Next
        'End If
        dgv.AutoGenerateColumns = False
        dgv.DataSource = dt
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If dgv.SelectedRows.Count > 0 Then
            Dim s_m As String = dgv.SelectedRows(0).Cells("support_model").Value.ToString()
            Dim o_c As String = dgv.SelectedRows(0).Cells("ColOperCount").Value.ToString()
            Dim f_c As String = dgv.SelectedRows(0).Cells("Col_finish_count_bg").Value.ToString()
            Dim rtn As Integer = objWorkshopCurrent.SaveData(dgv.SelectedRows(0).Cells("b_pgd_mes_sys_id").Value.ToString(),
                                                              s_m, "0", current_section, o_c, f_c)
            If rtn = -2 Then
                MsgBox(btnSave.Text + "失败")
            Else
                MsgBox(btnSave.Text + "成功")
                CType(Owner, FormYZZH).initForm()
            End If
        Else
            MsgBox("请选择需设定的生产计划")
        End If
    End Sub

End Class